package cn.shop.transcation.common.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.OrderBy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * @author : 李一涵
 * @date : Created in 2021-11-8 11:05
 * @description : 实体类基类
 */
public class BaseEntity {

	/**
	 * 编号
	 */
	@OrderBy
	private Long id;

	/**
	 * 商户编号
	 */
	@TableField(fill = FieldFill.INSERT)
	private Long uid;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@JsonInclude(Include.NON_NULL)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime createTime;

	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE, select = false)
	@JsonIgnore
	private LocalDateTime updateTime;

	/**
	 * 删除标记
	 */
	@TableLogic
	@JsonIgnore
	private Boolean deleted;

	/**
	 * 创建人id
	 */
	@TableField(fill = FieldFill.INSERT, select = false)
	@JsonInclude(Include.NON_NULL)
	private Long createId;

	/**
	 * 更新人id
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE, select = false)
	@JsonIgnore
	private Long updateId;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUid() {
		return uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}

	public LocalDateTime getCreateTime() {
		return createTime;
	}

	public void setCreateTime(LocalDateTime createTime) {
		this.createTime = createTime;
	}

	public LocalDateTime getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(LocalDateTime updateTime) {
		this.updateTime = updateTime;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public Long getCreateId() {
		return createId;
	}

	public void setCreateId(Long createId) {
		this.createId = createId;
	}

	public Long getUpdateId() {
		return updateId;
	}

	public void setUpdateId(Long updateId) {
		this.updateId = updateId;
	}

	@Override
	public String toString() {
		return "BaseEntity{" +
				"id=" + id +
				", uid=" + uid +
				", createTime=" + createTime +
				", updateTime=" + updateTime +
				", deleted=" + deleted +
				", createId=" + createId +
				", updateId=" + updateId +
				'}';
	}

}
